File: Win4dos.e
File: Windows type stuff for DOS32
Author: Hayden MvKay
hmck@dodo.com.au
3rd\Dec\2003

flat_win()
sunk_win()
tool_bar()
tool_button()
link_tool()
reset_tool()
clear_tools()
button()
clear_buttons()
look_tool()         *MUST BE PLACED IN LOOP FOR TOOLS
look_button()      *MUST BE PLACED IN LOOP FOR BUTTONS
imbeded_tool()     

NOTES REGARDING BUTTON AND TOOL NUMBERING.
             tools are automaticly numbered from 1 =>
             buttons are automaticly numberd from 1 =>
A quick show you;
                       tool_but() -- no 1
                       tool_but() -- no 2
                       button() -- no 1
                       tool_but() -- no 3
                       button() --no 2
                       * SEE HOW THEY NUMBER. SEE EXAMPLES AT BOTTOM OF PAGE.
* The mouse turns off and on during drawing procedures.
GLOBAL CONSTANTS :   SB_BACK
                                 ST_DOWN

GLOBAL PROCEDURES:
-----------------------------------------------------------------------------------------------------------------------------------------
flat_win(color,{top_X,top_Y},{bot_X,bot_Y},"text") = flat_win(i,{i,i},{i,i},"s")
sunk_win(color,{top_X,top_Y},{bot_X,bot_Y},"text") = sunk_win(i,{i,i},{i,i},"s")

color = title bar color 
top_X & top_Y = top co-ords
bot_X,& bot_Y = bot co-ords
text = title bar text
* Example:  flat_win(BLUE,{20,20},{300,300},"New Window")
-------------------------------------------------------------------------------------------------------------------------------------------
tool_bar()

adds a tool bar to the last window drawn.
* Example: tool_bar()  
-------------------------------------------------------------------------------------------------------------------------------------------
tool_button("*.bmp",mode) = tool_button("s",i)

adds a tool button to the last toolbar drawn. You can add as many buttons as you like.
Tool bar buttons are automaticly assighned a #number for identification, consecuativly. 
*.bmp = a file name and/or path to a 32x32 bitmap. Standard "read_bitmap()" rules apply.
mode = SP_BACK or ST_DOWN.  Spring back or stay down. 
* Example:  tool_button("C:\\Euhporia\\Bin\\Pics\\Floppy.bmp",SP_BACK) -- tool no. 1
   Example:  tool_button("C:\\Euhporia\\Bin\\Pics\\Folder.bmp",SP_BACK) -- tool no. 2
   32 x 32 bitmap is drawn once then disgarded. Only the shaddows are redrawn upon pressing.

--------------------------------------------------------------------------------------------------------------------------------------------
link_tool({tools},mode) = link_tool({i,i,i,i,i},mode)

links tool bar buttons. you cannot assighn an active tool# already in a link to another link. 
If you do, the tool# will be ignored by the new link and continue to function in its already assighned link.
You can use as many links as you like. Standard buttons are not linkable.
tools = tool bar buttons to be link.
mode = SP_BACK, or ST_DOWN.  Spring back or stay down.
* Example:  link_tool({2,4,6,7},ST_DOWN)
You can have mixed tool button types. SP_BACK links pop up any accossiated button when another is pressed.
ST_DOWN links stay down until a SP_BACK button is pressed. you need at least one SP_BACK button for this link to work.
-------------------------------------------------------------------------------------------------------------------------------------------
reset_tool(tool) = reset_tool(i)

depresses a tool button.
* Example:  reset_tool(3)
-------------------------------------------------------------------------------------------------------------------------------------------
clear_tools()

Completly deactivate all tool bar buttons.
Tools are reset to zero
New tools drawn after this call will start over from the number 1.
* Example: clear_tools()
--------------------------------------------------------------------------------------------------------------------------------------------
button({top_Y,top_X},{bot_Y,bot_X},"text") = button({i,i},{i,i},"s")

Draws a standard button.
New button are automaticly assighned a button# number.
top_X & top_Y = top co-ords.
bot_X & bot_Y = bot co-ords.
text = button text.
* Example: button({30,30},{130,55},"a button") -- button 1
  Example: button({140,30},{240,55},"b button") -- button 2
---------------------------------------------------------------------------------------------------------------------------------------------
clear_buttons()

Completely deactivate all buttons. 
Buttons are reset to zero.
New buttons drawn after this call will start over from the number 1.
* Example: clear_buttons()
---------------------------------------------------------------------------------------------------------------------------------------------
GLOBAL FUNCTIONS:
   
tool = look_tool(mouse) =   i = look_tool(x) *MUST BE PLACED IN LOOP FOR TOOLS TO WORK

looks for tool bar activity.
tool = the tool number returned from a pressed tool, else returns -1.
mouse = an object returned from get_mouse()
* Example:        integer tool
                       object mouse
                       mouse_pointer(1)
                       while 1 do
                           mouse =  get_mouse()
                           tool = look_tool(mouse)
                           if tool = 1 then
                               read_floppy()
                               elsif tool = 2 then
                                   open_window()
                           end if
-----------------------------------------------------------------------------------------------------------------------------------------------
button = look_button(mouse) =   i = look_button(x) *MUST BE PLACE IN LOOP FOR BUTTONS TO WORK

looks for button activity.
button = the tool number returned from a pressed tool, else returns -1.
mouse = an object returned from get_mouse()
* Example:        integer button
                       object mouse
                       mouse_pointer(1)
                       while 1 do
                           mouse =  get_mouse()
                           button = look_tool(mouse)
                           if button = 1 then
                               read_floppy()
                               elsif tool = 2 then
                                   open_window()
                           end if
-------------------------------------------------------------------------------------------------------------------------------------------------
MAIN LOOP EXAMPLE:
                              integer tool,button
                              object mouse
                              mouse_pointer(1)
                              while 1 do
                                  mouse = get_mouse()
                                  tool = look_tool(mouse)
                                  button = look_button(mouse)
                                  if tool = 1 then
                                       puts(1," you pressed tool 1")
                                       elsif tool = 2 then
                                            puts(1," you pressed tool 2")
                                            elsif button = 1 then
                                                 puts(1," you pressed button 1)
                                                 elsif button = 2 then
                                                      puts(1," you pressed abort!")
                                                      abort(1)
                                   end if 
                                end while
OR:  ------------------------------------------------------------------------------------------------
                              integer tool,button
                              object mouse
                              mouse_pointer(1)
                              while 1 do
                                  mouse = get_mouse()
                                  tool = look_tool(mouse)
                                  button = look_button(mouse)
                                  if tool = 1 then
                                       puts(1," you pressed tool 1")
                                       elsif tool = 2 then
                                            puts(1," you pressed tool 2")
                                  end if
                                  if button = 1 then
                                       puts(1," you pressed button 1")
                                       elsif button = 2 then
                                             puts(1," You pressed abort!")
                                             abort(1)
                                  end if
                              end while
OR:  ------------------------------------------------------------------------------------------------
                              integer tool,button
                              object mouse
                              mouse_pointer(1)
                              while 1 do
                                  mouse = get_mouse()
                                  tool = look_tool(mouse)
                                  if tool = 1 then
                                       puts(1," you pressed tool 1")
                                       elsif tool = 2 then
                                            puts(1," you pressed tool 2")
                                  end if
                                  button = look_button(mouse)
                                  if button = 1 then
                                       puts(1," you pressed button 1")
                                       elsif button = 2 then
                                             puts(1," You pressed abort!")
                                             abort(1)
                                  end if
                              end while
-----------------------------------------------------------------------------------------------------------------------------------------------                        
imbeded_tool(sequence,mode) = imbeded_tool(s,i)

an alternitive to tool_button that lets you bypass loading bitmaps so you can use an embeded/declared sequence .

Example:     sequence folder
                  folder = {{15,0,15,15,15,15,8,15,15,15,15,15,15,15,15,15},
	   {0,7,14,14,14,14,14,3,15,15,15,15,15,15,15,15},
	   {8,7,7,7,7,7,7,7,8,8,8,8,8,8,8,0},
	   {8,14,14,14,14,14,14,14,14,14,14,14,14,14,14,0},
	   {8,14,14,14,14,14,14,14,14,14,14,14,14,14,14,0},
	   {8,3,14,14,14,14,14,14,3,3,3,3,3,14,14,0},
	   {8,3,0,14,3,3,3,0,0,0,0,0,0,0,14,0},
	   {8,3,3,3,3,0,3,0,1,9,0,2,0,0,14,0},
	   {8,14,9,14,3,9,9,0,9,9,0,2,2,0,14,0},
	   {8,3,14,9,14,9,14,0,9,1,0,0,2,0,14,0},
	   {8,3,0,14,3,3,3,0,0,0,0,3,0,0,14,0},
	   {3,3,3,0,3,0,3,0,12,12,0,14,14,0,3,0},
	   {0,0,4,0,0,0,0,0,12,12,0,14,14,0,0,0},
	   {15,0,0,0,0,4,0,0,0,0,0,0,0,0,15,15},
	   {15,0,0,15,0,0,0,0,0,0,0,0,0,0,15,15},
	   {15,15,0,0,0,0,0,0,15,15,15,15,15,0,15,15}
imbeded_tool(folder,SP_BACK)


   